#version 150

in vec2 texCoord;
in float fogDistance;
out vec4 fragColor;

uniform sampler2D Sampler2D;
uniform vec4 RedFogColor;
uniform float FogStart;
uniform float FogEnd;

void main() {
    vec4 color = texture(Sampler2D, texCoord);
    
    // 计算雾因子 (线性雾)
    float fogFactor = clamp((FogEnd - fogDistance) / (FogEnd - FogStart), 0.0, 1.0);
    
    // 混合原始颜色和雾颜色
    fragColor = mix(RedFogColor, color, fogFactor);
    
    // 保持原始Alpha值
    fragColor.a = color.a;
}